package com.boxuegu.caihuaxuan24.myapplication.activity;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.RelativeLayout;

import com.boxuegu.caihuaxuan24.myapplication.R;
import com.boxuegu.caihuaxuan24.myapplication.fragment.courseFragment;
import com.boxuegu.caihuaxuan24.myapplication.fragment.exerciseFragment;
import com.boxuegu.caihuaxuan24.myapplication.fragment.myFragment;

public class MainActivity extends AppCompatActivity {
    RelativeLayout mCouseBtn,mExerciseBtn,myBtn;
    Fragment courseframeLayout = new courseFragment();
    Fragment exerfragment = new exerciseFragment();
    Fragment myFrament = new myFragment();
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        getSupportFragmentManager().beginTransaction().replace(R.id.layout,courseframeLayout).commit();
        mExerciseBtn = findViewById(R.id.exerciselayout);
        mExerciseBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                getSupportFragmentManager().beginTransaction().replace(R.id.layout,exerfragment).commit();
                mCouseBtn.setSelected(false);
                mExerciseBtn.setSelected(true);
                myBtn.setSelected(false);
            }
        });
        mCouseBtn = findViewById(R.id.couselayout);
        mCouseBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                getSupportFragmentManager().beginTransaction().replace(R.id.layout,courseframeLayout).commit();
                mCouseBtn.setSelected(true);
                mExerciseBtn.setSelected(false);
                myBtn.setSelected(false);
            }
        });
        myBtn =findViewById(R.id.mylayout);
        myBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                getSupportFragmentManager().beginTransaction().replace(R.id.layout,myFrament).commit();
                mCouseBtn.setSelected(false);
                mExerciseBtn.setSelected(false);
                myBtn.setSelected(true);
            }
        });

        mCouseBtn.setSelected(true);
        mExerciseBtn.setSelected(false);
        myBtn.setSelected(false);
    }
}
